home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / update~4.z / update~4 / lib_stdio_exit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  931 b   |  42 lines

  1. /*                e x i t
  2.  *
  3.  * Exit with stdio wrap up. A scan is made of the exit handler list.
  4.  * All non-null pointers will be used to call the named functions.
  5.  * Finally the stdio exit handler, _ioflush(), is called, followed by an
  6.  * _exit().
  7.  *
  8.  * Patchlevel 1.1
  9.  *
  10.  * Edit History:
  11.  * 06-Sep-1989    Corrected prototypes. Correct exit handler table
  12.  *        initialisation. Lint control.
  13.  * 05-Sep-1989    Created.
  14.  */
  15.  
  16. #include "stdiolib.h"
  17.  
  18. /*LINTLIBRARY*/
  19.  
  20. #define MAX_HANDLERS    15        /* maximum number of handlers */
  21.  
  22. void exit    P((int));            /* exit coming up */
  23.  
  24. /* Exit handler list */
  25. static void (*_exit_list[MAX_HANDLERS+1]) P((void)) = {_ioflush};
  26.  
  27. /* Exit handler list pointer */
  28. void (**_exit_hp) P((void)) = &_exit_list[MAX_HANDLERS];
  29.  
  30. void exit(status)
  31.  
  32. int status;                /* exit status */
  33.  
  34. {
  35.   int _exit P((int));            /* exit */
  36.  
  37.   for ( ; _exit_hp < &_exit_list[MAX_HANDLERS]; )
  38.     (*++_exit_hp)();
  39.   _ioflush();
  40.  (void) _exit(status);
  41. }
  42.